package main

import (
	"github.com/micro/go-micro/v2/web"
	"go.uber.org/zap"
	"user_api/global"
	"user_api/initialize"
)

func main() {

	//1. 初始化logger
	zap.S().Debug("初始化logger")
	initialize.InitLogger()

	//2. 初始化srv的连接
	zap.S().Debug("初始化srv的连接")
	initialize.InitSrvConn()

	//3. 初始化routers
	zap.S().Debug("初始化routers")
	ginRouter := initialize.Routers()

	//4.语言转换
	if err := initialize.InitTrans("zh"); err != nil {
		panic(err)
	}

	//__.注册验证器
	//if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
	//	_ = v.RegisterValidation("email", myvalidator.ValidateEmail)
	//}

	//5. 注册服务
	zap.S().Debug("注册服务")
	microService := web.NewService(
		web.Name("user.client"),
		web.Address(":18001"),
		web.Registry(global.ConsulClient),
		web.Handler(ginRouter),
	)

	err := microService.Run()
	if err != nil {
		return
	}

}
